﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.ListItemCreationInformation", ValueObject=true, ServerTypeId="{54cdbee5-0897-44ac-829f-411557fa11be}")]
    public sealed class ListItemCreationInformation : ClientValueObject
    {
        private string m_folderUrl;
        private string m_leafName;
        private FileSystemObjectType m_underlyingObjectType;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            string str = peekedName;
            if (str != null)
            {
                if (!(str == "FolderUrl"))
                {
                    if (str == "UnderlyingObjectType")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_underlyingObjectType = reader.ReadEnum<FileSystemObjectType>();
                        return flag;
                    }
                    if (str == "LeafName")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_leafName = reader.ReadString();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.m_folderUrl = reader.ReadString();
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "FolderUrl");
            DataConvert.WriteValueToXmlElement(writer, this.FolderUrl, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "UnderlyingObjectType");
            DataConvert.WriteValueToXmlElement(writer, this.UnderlyingObjectType, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "LeafName");
            DataConvert.WriteValueToXmlElement(writer, this.LeafName, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public string FolderUrl
        {
            get
            {
                return this.m_folderUrl;
            }
            set
            {
                this.m_folderUrl = value;
            }
        }

        [Remote]
        public string LeafName
        {
            get
            {
                return this.m_leafName;
            }
            set
            {
                this.m_leafName = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{54cdbee5-0897-44ac-829f-411557fa11be}";
            }
        }

        [Remote]
        public FileSystemObjectType UnderlyingObjectType
        {
            get
            {
                return this.m_underlyingObjectType;
            }
            set
            {
                this.m_underlyingObjectType = value;
            }
        }
    }
}

